package cn.rkylin.oms.refund.adapter;

import cn.rkylin.oms.system.shop.vo.ShopVO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.rkylin.apollo.common.util.BeanUtils;
import cn.rkylin.oms.common.base.AbstractAdapterFactory;
import cn.rkylin.oms.item.adapter.ItemAdapterFactory;
import cn.rkylin.oms.system.shop.domain.Shop;

/**
 * 退款适配器工厂
 * 
 * @author jipengcheng
 * @version 1.0
 * @created 2017.02.13
 */
public class RefundAdapterFactory {
	private static final Log logger = LogFactory.getLog(ItemAdapterFactory.class);

	/**
	 * 构造函数
	 */
	private RefundAdapterFactory() {

	}

	/**
	 * 判断shopType创建具体的adapter
	 * 
	 * @param shopId
	 * @throws Exception
	 */
	public static RefundAdapter getRefundAdapter(String shopId) throws Exception {
		ShopVO shopVO = AbstractAdapterFactory.getShop(shopId);
		
		if(shopVO==null){
			return null;
		}
		
		String shopType = shopVO.getShopType();
		if (shopType.equals("淘宝")) {
			TaoBaoRefundAdapter taoBaoRefundAdapter = BeanUtils.getBean("taoBaoRefundAdapter");
			TaoBaoRefundVisitor taoBaoRefundVisitor = BeanUtils.getBean("taoBaoRefundVisitor");
			taoBaoRefundAdapter.setRefundVistor(taoBaoRefundVisitor);
			return taoBaoRefundAdapter;
		}
		return null;
	}

	public void finalize() throws Throwable {

	}

}
